import loadable from "react-loadable";
import { RouteConfig } from "react-router-config";
import Loading from "../component/Loading";
import DoctorOrderRouter from "../views/doctor-order/DoctorOrderRouter";
import RouterSure from "../views/doctor-order/RouterSure";
import ChooseDoctorRouter from "../views/hospital-order/ChooseDoctorRouter";
import HospitalInto from "../views/hospital-order/HospitalInto";
import MainIndex from "../views/layout/MainIndex";

const Register = loadable({
  loader: () => import("../views/register/Register"),
  loading: Loading
});
const ChooseDoctor = loadable({
  loader: () => import("../views/hospital-order/ChooseDoctor"),
  loading: Loading
});
const Login = loadable({
  loader: () => import("../views/login-in/Login"),
  loading: Loading
});
const UserInfo = loadable({
  loader: () => import("../views/user-info/UserInfo"),
  loading: Loading
});
const DoctorOrder = loadable({
  loader: () => import("../views/doctor-order/DoctorOrder"),
  loading: Loading
});
const DoctorInfo = loadable({
  loader: () => import("../views/doctor-detail/DoctorInfo"),
  loading: Loading
});
// const ReservationRecord = loadable({
//   loader: () => import("../views/user-info/ReservationRecord"),
//   loading: Loading
// });
// const PatientManagement = loadable({
//   loader: () => import("../views/user-info/PatientManagement"),
//   loading: Loading
// });
const AccountSetting = loadable({
  loader: () => import("../views/user-info/AccountSetting"),
  loading: Loading
});
const HospitalIndex = loadable({
  loader: () => import("../views/hospital-order/Index"),
  loading: Loading
});
// const ChoosePatient = loadable({
//   loader: () => import("../views/choose-patient/ChoosePatient"),
//   loading: Loading
// });
const EstimateDoctor = loadable({
  loader: () => import("../views/doctor-order/EstimateDoctor"),
  loading: Loading
});
/**
 * 路由配置：其路由的详情可以路由的递归关系查看相应的地址到相应的组件
 * *****暂时未使用这种方式
 */
const routerConfigs: RouteConfig[] = [
  {
    component: Register,
    path: "/register"
  },
  {
    component: Login,
    exact: true,
    path: "/login"
  },
  {
    component: MainIndex,
    path: "/",
    // @ts-ignore
    routes: [
      {
        component: DoctorOrderRouter,
        path: "/order-doctor",
        routes: [
          {
            component: RouterSure,
            path: "/order-doctor",
            routes: [
              {
                component: DoctorOrder,
                path: "/order-doctor",
                exact: true
              },
              {
                component: DoctorInfo,
                path: "/order-doctor/doctor-detail"
              },
              // {
              //   component: ChoosePatient,
              //   path: "/order-doctor/choose-patient"
              // },
              {
                component: EstimateDoctor,
                path: "/order-doctor/estimate-doctor"
              }
            ]
          }
        ]
      },
      {
        component: UserInfo,
        path: "/user-info",
        routes: [
          // {
          //   component: ReservationRecord,
          //   path: "/user-info",
          //   exact: true
          // },
          // {
          //   component: PatientManagement,
          //   path: "/user-info/patient-management",
          //   exact: true
          // },
          {
            component: AccountSetting,
            path: "/user-info/account-setting",
            exact: true
          }
        ]
      },
      {
        component: DoctorInfo,
        exact: true,
        path: "/doctor-detail"
      },
      {
        component: HospitalIndex,
        path: "/",
        routes: [
          {
            component: HospitalInto,
            path: "/",
            exact: true
          },
          {
            component: ChooseDoctorRouter,
            path: "/choose-doctor",
            routes: [
              {
                component: DoctorInfo,
                exact: true,
                path: "/choose-doctor/doctor-detail"
              },
              {
                component: ChooseDoctor,
                exact: true,
                path: "/choose-doctor"
              }
            ]
          }
        ]
      }
    ]
  }
];
export default routerConfigs;
